<?php
/*
	插件概览		
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'welcome';
$tabs=array(
	array('op'=>'welcome','title'=>'概况'),
	array('op'=>'line','title'=>'趋势'),
);
set_html('tabs',$tabs);
if($_RQ['op']=='welcome'){
	//会员
	$order=array(
		'num'=>pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'ispay'=>1,'sendtype'=>2,'merchid'=>$merchid)),
		'order_price'=>pdo_getsum('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'ispay'=>1,'sendtype'=>2,'merchid'=>$merchid),'price'),
	);
	$return['htmls'][]=array('type'=>'data','one_num'=>4,'title'=>'上门自提','datas'=>array(
		array('title'=>'总订单数','num'=>1,'data'=>$order['num']),
		array('title'=>'总订单额','num'=>1,'data'=>$order['order_price']),
		array('title'=>'总上门次数','num'=>1,'data'=>$order['num']),
	));
	//佣金
	$data=array(
		'num'=>pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'ispay'=>1,'sendtype'=>1,'merchid'=>$merchid)),
		'order_price'=>pdo_getsum('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'ispay'=>1,'sendtype'=>1,'merchid'=>$merchid),'price'),
		'get_money'=>pdo_count('jy_peimilk_orderlog',array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid),'get_money'),
	);
	$return['htmls'][]=array('type'=>'data','one_num'=>4,'title'=>'配送上门','datas'=>array(
		array('title'=>'总订单数','num'=>1,'data'=>$data['num']),
		array('title'=>'总订单额','num'=>1,'data'=>$data['ordernum']),
		array('title'=>'总配送费','num'=>1,'data'=>$order['get_money']),
	));	
	$order_pie=array(
		'title'=>'类目概况',
		'tablename'=>'jy_weishop_order',
		'width'=>'50%',
		'field'=>'sendtype',
		'field_options'=>$this->send_types,
		'params'=>array('ispay'=>1,'uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid),
	);
	$return['htmls'][]=model('core/echart')->pie($order_pie);
	$fee_pie=array(
		'title'=>'配送费概况',
		'tablename'=>$this->tablename('orderlog'),
		'width'=>'50%',
		'field'=>'type',
		'field_options'=>$this->feetypes,
		'params'=>array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid),
	);
	$return['htmls'][]=model('core/echart')->pie($fee_pie);
	set_html('title','类目概况');
	exi($return);
}
if($_RQ['op']=='line'){
	$member_params=array(
		'title'=>'上门自提/配送上门',
		'data'=>array(
			'上门自提'=>array(
				'tablename'=>'jy_weishop_order',
				'params'=>array('uniacid'=>$_SESSION['uniacid'],'ispay'=>1,'sendtype'=>2,'merchid'=>$merchid),
			),
			'配送上门'=>array(
				'tablename'=>'jy_weishop_order',
				'params'=>array('uniacid'=>$_SESSION['uniacid'],'ispay'=>1,'sendtype'=>1,'merchid'=>$merchid),
			)
		),
	);
	$return['htmls'][]=model('core/echart')->line($member_params);
	set_html('title','类目趋势');
	exi($return);
}